package _99

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func rightSideView(root *TreeNode) []int {
	if root == nil {
		return nil
	}
	results := make([]int, 0)
	results = append(results, root.Val)
	doRightSlideView(root.Right, &results)
	return results
}

func doRightSlideView(root *TreeNode, results *[]int) {
	if root == nil {
		return
	}
	*results = append(*results, root.Val)
	doRightSlideView(root.Right, results)
}
